<template>
  <div id="area">
    <div class="area-top">
      <h3>地区</h3>
      <el-button type="primary" @click="dialogFormVisible = true">新增</el-button>
      <el-button type="primary">导入</el-button>
      <el-button type="">导出</el-button>
    </div>
    <div class="area-content">
      <el-table height="500px" :data="areas" border style="width: 100%;font-size: 13px;margin-left: 20px;">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column prop="areaCode" label="地区编号" width="200">
        </el-table-column>
        <el-table-column prop="areaName" label="地区名称" width="200">
        </el-table-column>
        <el-table-column prop="employeeId" label="地区负责人" width="150">
        </el-table-column>
        <el-table-column prop="remark" label="备注" width="120">
        </el-table-column>
        <el-table-column prop="status" label="是否启用" width="120">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.status" active-color="#66b1ff" inactive-color="#c1c1c1" active-value="1"
              inactive-value="0">
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination style="position: relative;left: 700px;bottom: 30px;" @size-change="handleSizeChange"
      @current-change="handleCurrentChange" :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]"
      :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total="400">
    </el-pagination>
    <el-dialog width="500px" top="100px" title="新增账户" :visible.sync="dialogFormVisible">
      <AddArea />
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import AddArea from './AddArea.vue';

export default {
  name: 'Area',
  components: {
    AddArea
  },
  data() {
    return {
      dialogFormVisible: false,
      //分页参数
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 4,
      areas: [
        {
          areaCode: 'test1',
          areaName: 'test1',
          employeeId: '11',
          remark: '',
          status: '1'
        },
        {
          areaCode: 'test1',
          areaName: 'test1',
          employeeId: '11',
          remark: '',
          status: '1'
        },
        {
          areaCode: 'test1',
          areaName: 'test1',
          employeeId: '11',
          remark: '',
          status: '1'
        },
      ]
    }

  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
}
</script>

<style scoped>
#area {
  width: 100%;
  height: 100%;
}

.area-top {
  width: calc(100% -20px);
  height: 60px;
  /* background-color: pink; */
  line-height: 60px;
  padding-left: 20px;
  font-size: 13px;
}

.area-top h3 {
  display: inline-block;
  margin-right: 1000px;
}

.area-content {
  width: 100%;
  height: calc(100% - 60px);
  /* background-color: skyblue; */
}

.el-input,
.el-button {
  font-size: 13px;
}
</style>